package com.sz.rexiang.Activity;

import org.xutils.x;
import org.xutils.view.annotation.Event;
import org.xutils.view.annotation.ViewInject;

import com.sz.rexiang.R;

import android.app.Activity;
import android.os.Build.VERSION;
import android.os.Build.VERSION_CODES;
import android.os.Bundle;
import android.view.View;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.TextView;

public class BaseActivity extends Activity {

	@ViewInject(R.id.ac_main_titletv)
	public TextView tvTitle;
	@ViewInject(R.id.ac_main_back)
	public ImageView imgBack;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);

		x.view().inject(this);
		if (VERSION.SDK_INT >= VERSION_CODES.KITKAT) {
			getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
			getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
		}
	}

	public void setTitle(int resIDTitle, boolean b) {

		tvTitle.setText(resIDTitle);
		if (b)
			imgBack.setVisibility(View.VISIBLE);
		else
			imgBack.setVisibility(View.GONE);

	}

	@Event(value = { R.id.ac_main_back }, type = View.OnClickListener.class)
	private void onClick(View view) {
		// 必须为private
		switch (view.getId()) {
		case R.id.ac_main_back:
			finish();
			break;
		}
	}

}
